from aop.aop_config import load_global_config
from sync import get_range_time
from sync.sync_order import main as sync_order_main
from sync.sync_order_goods import main as sync_order_goods_main
from sync.sync_order_goods_tb import main as sync_order_goods_tb_main
from sync.sync_order_tb import main as sync_order_tb_main
from sync.sync_ordered_bidding import main as sync_ordered_bidding_main
from sync.sync_outer_goods import main as sync_outer_goods_main
from sync.sync_outer_goods_sku import main as sync_outer_goods_sku_main
from sync.sync_outer_goods_sku_log import main as sync_outer_goods_sku_log_main
from sync.sync_z_after_all_synced import main as sync_z_after_all_synced_update_main


@load_global_config('../config/config.json5')
def main():
    start, end = get_range_time()
    sync_order_main(start, end)
    sync_order_goods_main(start, end)
    sync_order_goods_tb_main(start, end)
    sync_order_tb_main(start, end)
    sync_ordered_bidding_main(start, end)
    sync_outer_goods_main(start, end)
    sync_outer_goods_sku_main(start, end)
    sync_outer_goods_sku_log_main(start, end)
    sync_z_after_all_synced_update_main()
    print('sync done')
    # processes = [
    #     multiprocessing.Process(target=sync_order_main, args=[start, end]),
    #     multiprocessing.Process(target=sync_order_goods_main, args=[start, end]),
    #     multiprocessing.Process(target=sync_order_goods_tb_main, args=[start, end]),
    #     multiprocessing.Process(target=sync_order_tb_main, args=[start, end]),
    #     multiprocessing.Process(target=sync_ordered_bidding_main, args=[start, end]),
    #     multiprocessing.Process(target=sync_outer_goods_main, args=[start, end]),
    #     multiprocessing.Process(target=sync_outer_goods_sku_main, args=[start, end]),
    #     multiprocessing.Process(target=sync_outer_goods_sku_log_main, args=[start, end]),
    # ]
    #
    # for p in processes:
    #     p.start()
    #
    # for p in processes:
    #     p.join()


if __name__ == '__main__':
    main()
